// A3. Distance from School and Child Development (without controls)
// A3. Distance from School and Child Development (without controls)
// A3. Distance from School and Child Development (without controls)


// PRELIMINARIES

clear
set more off
set scheme s1mono



// LOAD DATA
	
use "JakielaOzierFernaldKnauer-preschool-data.dta", replace



// FREDUCED FORM RESULTS


** a. reduced form ECD index

forvalues i = 3/6 {
	reg ecdindex schdist if roundage==`i', cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}
cap file close fh
file open fh using "out/A3A-rfecd.tex", write replace

file write fh "Distance to school (km) & `_beta3' & `_beta4' & `_beta5' & `_beta6'  \\ [0.8ex] " _newline
file write fh "		    & (`_se3') & (`_se4') & (`_se5') & (`_se6')  \\ [0.8ex] " _newline
file write fh "		    & [`_pval3'] & [`_pval4'] & [`_pval5'] & [`_pval6']  \\ [0.8ex] " _newline

file close fh


** b. reduced form luo receptive vocab

forvalues i = 3/6 {
	reg zluovocab schdist if roundage==`i', cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}
cap file close fh
file open fh using "out/A3B-rfluo.tex", write replace

file write fh "Distance to school (km) & `_beta3' & `_beta4' & `_beta5' & `_beta6'  \\ [0.8ex] " _newline
file write fh "		    & (`_se3') & (`_se4') & (`_se5') & (`_se6')  \\ [0.8ex] " _newline
file write fh "		    & [`_pval3'] & [`_pval4'] & [`_pval5'] & [`_pval6']  \\ [0.8ex] " _newline

file close fh


** c. reduced form english receptive vocab

forvalues i = 3/6 {
	reg zengvocab schdist if roundage==`i', cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}
cap file close fh
file open fh using "out/A3C-rfeng.tex", write replace

file write fh "Distance to school (km) & `_beta3' & `_beta4' & `_beta5' & `_beta6'  \\ [0.8ex] " _newline
file write fh "		    & (`_se3') & (`_se4') & (`_se5') & (`_se6')  \\ [0.8ex] " _newline
file write fh "		    & [`_pval3'] & [`_pval4'] & [`_pval5'] & [`_pval6']  \\ [0.8ex] " _newline

file close fh



** d. reduced form expressive vocab

forvalues i = 3/6 {
	reg zexpvocab schdist if roundage==`i', cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}
cap file close fh
file open fh using "out/A3D-rfexp.tex", write replace

file write fh "Distance to school (km) & `_beta3' & `_beta4' & `_beta5' & `_beta6'  \\ [0.8ex] " _newline
file write fh "		    & (`_se3') & (`_se4') & (`_se5') & (`_se6')  \\ [0.8ex] " _newline
file write fh "		    & [`_pval3'] & [`_pval4'] & [`_pval5'] & [`_pval6']  \\ [0.8ex] " _newline

file close fh


** e. reduced form fine motor

forvalues i = 3/6 {
	reg zmotor schdist if roundage==`i', cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}
cap file close fh
file open fh using "out/A3E-rfmotor.tex", write replace

file write fh "Distance to school (km) & `_beta3' & `_beta4' & `_beta5' & `_beta6'  \\ [0.8ex] " _newline
file write fh "		    & (`_se3') & (`_se4') & (`_se5') & (`_se6')  \\ [0.8ex] " _newline
file write fh "		    & [`_pval3'] & [`_pval4'] & [`_pval5'] & [`_pval6']  \\ [0.8ex] " _newline

file close fh

cap file close fh
file open fh using "out/A3-rfinfo.tex", write replace

file write fh "Obs. & `_obs3' & `_obs4' & `_obs5' & `_obs6'  \\ [0.8ex] " _newline

file close fh
